import { createRouter, createWebHashHistory } from 'vue-router'
const Layout = () => import('@/views/Layout')
const Home = () => import('@/views/Home')
const Goods = () => import('@/views/Goods')
// 登录页面
const Login = () => import('@/views/Login')
// 购物车页面
const Cart = () => import('@/views/Cart')
// 下单详情页面
const Order = () => import('@/views/Member/settlement')
// 路由的配置规则
const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '/',
        component: Home
      },
      {
        path: '/goods/:id',
        component: Goods
      },
      {
        path: '/cart',
        component: Cart
      },
      {
        path: '/order',
        component: Order
      }
    ]
  },
  {
    path: '/login',
    component: Login
  }
]
const router = createRouter({
  history: createWebHashHistory(),
  routes,
  // 每次切换页面的时候，滚动条到顶部
  scrollBehavior () {
    return { left: 0, top: 0 }
  }
})
export default router
